package com.example.administrator.demo;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.example.administrator.demo.R;
import com.example.administrator.demo.recycle.RecyclerViewAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * projectName rxjavademo
 * date 2017/7/21
 * description com.example.administrator.demo.recycle
 */

public class CommonRecyclerViewActivity extends Activity {

    private RecyclerView mRecyclerView;
    private List<String> mDatas;
    private RecyclerViewAdapter mAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyclerview_common);
        initData();
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = new RecyclerViewAdapter<String>(this, R.layout.item_home, mDatas) {
            @Override
            public void convert(CommonViewHolder holder, int position, String s) {
                TextView view = holder.getView(R.id.id_num);
                view.setText(s);
            }
        };
        mRecyclerView.setAdapter(mAdapter);
    }

    protected void initData() {
        mDatas = new ArrayList<String>();
        for (int i = 'A'; i < 'z'; i++)
        {
            mDatas.add("" + (char) i);
        }
    }
}
